<!-- 搜索表单 -->
<template>
  <ele-card :body-style="{ paddingBottom: '2px' }">
    <el-form
      ref="formRef"
      inline=""
      :model="form"
      label-width="80px"
      @keyup.enter="search"
    >
      <el-form-item label="会员姓名" prop="realname">
        <el-input
          clearable
          :maxlength="20"
          v-model="form.realname"
          placeholder="用户姓名"
        />
      </el-form-item>

      <el-form-item label="联系电话" prop="tel">
        <el-input clearable :maxlength="20" v-model="form.tel" />
      </el-form-item>

      <el-form-item label="" prop="">
        <el-button type="primary" :loading="loading" @click="search">
          查找所有用户
        </el-button>
      </el-form-item>
    </el-form>
  </ele-card>
</template>

<script setup>
  import { ref } from 'vue';
  import { useFormData } from '@/utils/use-form-data';
  const emit = defineEmits(['search']);

  /** 表单数据 */
  const [form] = useFormData({
    realname: '',
    tel: ''
  });

  const loading = ref(false);

  /** 搜索 */
  const search = () => {
    emit('search', { ...form });
  };
</script>
